﻿using System.Collections.Generic;
using System.Web.Mvc;
using Microsoft.Practices.EnterpriseLibrary.Validation;

namespace ElValWeb {
    public class EntLibValidatorProvider : ModelValidatorProvider {
        public override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context) {
            var validator = ValidationFactory.CreateValidator(metadata.ModelType);

            if (validator != null) {
                yield return new EntLibValidatorWrapper(metadata, context, validator);
            }
        }

        
    }
}